<!DOCTYPE html>
<html>

<head>
  <title>Building Quarkus apps with Gradle</title>
  <script id="adobe_dtm" src="https://www.redhat.com/dtm.js" type="text/javascript"></script>
  <script src="/assets/javascript/highlight.pack.js" type="text/javascript"></script>
  <META HTTP-EQUIV='Content-Security-Policy' CONTENT="default-src 'none'; script-src 'self' 'unsafe-eval' 'sha256-ANpuoVzuSex6VhqpYgsG25OHWVA1I+F6aGU04LoI+5s=' 'sha256-ipy9P/3rZZW06mTLAR0EnXvxSNcnfSDPLDuh3kzbB1w=' js.bizographics.com https://www.redhat.com assets.adobedtm.com jsonip.com https://ajax.googleapis.com https://www.googletagmanager.com https://www.google-analytics.com https://use.fontawesome.com; style-src 'self' https://fonts.googleapis.com https://use.fontawesome.com; img-src 'self' *; media-src 'self' ; frame-src https://www.googletagmanager.com https://www.youtube.com; frame-ancestors 'none'; base-uri 'none'; object-src 'none'; form-action 'none'; font-src 'self' https://use.fontawesome.com https://fonts.gstatic.com;">
  <META HTTP-EQUIV='X-Frame-Options' CONTENT="DENY">
  <META HTTP-EQUIV='X-XSS-Protection' CONTENT="1; mode=block">
  <META HTTP-EQUIV='X-Content-Type-Options' CONTENT="nosniff">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="description" content="Quarkus: Supersonic Subatomic Java">
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:site" content="@QuarkusIO"> 
  <meta name="twitter:creator" content="@QuarkusIO">
  <meta property="og:url" content="https://quarkus.io/guides/gradle-tooling" />
  <meta property="og:title" content="Building Quarkus apps with Gradle" />
  <meta property="og:description" content="Quarkus: Supersonic Subatomic Java" />
  <meta property="og:image" content="/assets/images/quarkus_card.png" />
  <link rel="canonical" href="https://quarkus.io/guides/gradle-tooling">
  <link rel="shortcut icon" type="image/png" href="/favicon.ico" >
  <link rel="stylesheet" href="https://quarkus.io/guides/stylesheet/config.css" />
  <link rel="stylesheet" href="/assets/css/main.css" />
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">
  <link rel="alternate" type="application/rss+xml"  href="https://quarkus.io/feed.xml" title="Quarkus">
  <script src="https://quarkus.io/assets/javascript/goan.js" type="text/javascript"></script>
  <script src="https://quarkus.io/assets/javascript/hl.js" type="text/javascript"></script>
</head>

<body class="guides">
  <!-- Google Tag Manager (noscript) -->
  <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NJWS5L"
  height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
  <!-- End Google Tag Manager (noscript) -->

  <div class="nav-wrapper">
  <div class="grid-wrapper">
    <div class="width-12-12">
      <input type="checkbox" id="checkbox" />
      <nav id="main-nav" class="main-nav">
  <div class="container">
    <div class="logo-wrapper">
      
        <a href="/"><img src="/assets/images/quarkus_logo_horizontal_rgb_600px_reverse.png" class="project-logo" title="Quarkus"></a>
      
    </div>
    <label class="nav-toggle" for="checkbox">
      <i class="fa fa-bars"></i>
    </label>
    <div id="menu" class="menu">
      <span>
        <a href="/get-started/" class="">Get Started</a>
      </span>
      <span>
        <a href="/guides/" class="active">Guides</a>
      </span>
      <span>
        <a href="/community/" class="">Community</a>
      </span>
      <span>
        <a href="/support/" class="">Support</a>
      </span>
      <span>
        <a href="/blog/" class="">Blog</a>
      </span>
      <span>
        <a href="https://code.quarkus.io" class="button-cta secondary white">Start Coding</a>
      </span>
    </div>
  </div>
      </nav>
    </div>
  </div>
</div>

  <div class="content">
    <div class="guide">
  <div class="width-12-12">
    <h1 class="text-caps">Building Quarkus apps with Gradle</h1>
    <div class="hide-mobile toc"><ul class="sectlevel1">
<li><a href="#project-creation">Creating a new project</a>
<ul class="sectlevel2">
<li><a href="#custom-test-configuration-profile">Custom test configuration profile in JVM mode</a></li>
</ul>
</li>
<li><a href="#dealing-with-extensions">Dealing with extensions</a></li>
<li><a href="#development-mode">Development mode</a>
<ul class="sectlevel2">
<li><a href="#remote-development-mode">Remote Development Mode</a></li>
</ul>
</li>
<li><a href="#debugging">Debugging</a></li>
<li><a href="#import-in-your-ide">Import in your IDE</a></li>
<li><a href="#building-a-native-executable">Building a native executable</a>
<ul class="sectlevel2">
<li><a href="#build-a-container-friendly-executable">Build a container friendly executable</a></li>
</ul>
</li>
<li><a href="#running-native-tests">Running native tests</a></li>
<li><a href="#building-uber-jars">Building Uber-Jars</a>
<ul class="sectlevel2">
<li><a href="#multi-module-gradle">Working with multi-module projects</a></li>
</ul>
</li>
<li><a href="#building-with-gradlew-build">Building with <code>./gradlew build</code></a></li>
</ul></div>
    <div>
      <div id="preamble">
<div class="sectionbody">
<div class="admonitionblock caution">
<table>
<tr>
<td class="icon">
<i class="fa icon-caution" title="Caution"></i>
</td>
<td class="content">
Quarkus Gradle support is considered preview.
You can use Gradle to create Quarkus projects as outlined in our guides. If you go beyond there will be cases where
the Gradle tasks <a href="https://github.com/quarkusio/quarkus/issues/5101">does not behave as expected</a>.
This is just a caution, and we recommend if you like Gradle you try it out and give us feedback.
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="project-creation"><a class="anchor" href="#project-creation"></a>Creating a new project</h2>
<div class="sectionbody">
<div class="paragraph">
<p>The easiest way to scaffold a Gradle project, is currently to use the Quarkus Maven plugin like so:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">mvn io.quarkus:quarkus-maven-plugin:1.7.0.Final:create \
    -DprojectGroupId=my-groupId \
    -DprojectArtifactId=my-artifactId \
    -DprojectVersion=my-version \
    -DclassName="org.my.group.MyResource" \
    -Dextensions="resteasy-jsonb" \
    -DbuildTool=gradle</code></pre>
</div>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
If you just launch <code>mvn io.quarkus:quarkus-maven-plugin:1.7.0.Final:create</code> the Maven plugin asks
for user inputs. You can disable (and use default values) this interactive mode by passing <code>-B</code> to the Maven command.
</td>
</tr>
</table>
</div>
<div class="admonitionblock note">
<table>
<tr>
<td class="icon">
<i class="fa icon-note" title="Note"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Quarkus project scaffolding automatically installs the Gradle wrapper (<code>./gradlew</code>) in your project.</p>
</div>
<div class="paragraph">
<p>If you prefer to use a standalone Gradle installation, please use Gradle 6.5.1.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>The following table lists the attributes you can pass to the <code>create</code> command:</p>
</div>
<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 33.3333%;">
<col style="width: 33.3333%;">
<col style="width: 33.3334%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">Attribute</th>
<th class="tableblock halign-left valign-top">Default Value</th>
<th class="tableblock halign-left valign-top">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>projectGroupId</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>org.acme.sample</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The group id of the created project</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>projectArtifactId</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>mandatory</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The artifact id of the created project. Not passing it triggers the interactive mode.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>projectVersion</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>1.0-SNAPSHOT</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The version of the created project</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>className</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>Not created if omitted</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The fully qualified name of the generated resource</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>path</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>/hello</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The resource path, only relevant if <code>className</code> is set.</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>extensions</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><em>[]</em></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The list of extensions to add to the project (comma-separated)</p></td>
</tr>
</tbody>
</table>
<div class="paragraph">
<p>If you decide to generate a REST resource (using the <code>className</code> attribute), the endpoint is exposed at: <code><a href="http://localhost:8080/$path" class="bare">http://localhost:8080/$path</a></code>.
If you use the default <code>path</code>, the URL is: <a href="http://localhost:8080/hello" class="bare">http://localhost:8080/hello</a>.</p>
</div>
<div class="paragraph">
<p>The project is either generated in the current directory or in a directory named after the passed artifactId.
If the current directory is empty, the project is generated in-place.</p>
</div>
<div class="paragraph">
<p>A pair of Dockerfiles for native and jvm mode are also generated in <code>src/main/docker</code>.
Instructions to build the image and run the container are written in those Dockerfiles.</p>
</div>
<div class="sect2">
<h3 id="custom-test-configuration-profile"><a class="anchor" href="#custom-test-configuration-profile"></a>Custom test configuration profile in JVM mode</h3>
<div class="paragraph">
<p>By default, Quarkus tests in JVM mode are run using the <code>test</code> configuration profile. If you are not familiar with Quarkus
configuration profiles, everything you need to know is explained in the
<a href="config#configuration-profiles">Configuration Profiles Documentation</a>.</p>
</div>
<div class="paragraph">
<p>It is however possible to use a custom configuration profile for your tests with the Gradle build configuration shown below.
This can be useful if you need for example to run some tests using a specific database which is not your default testing
database.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="groovy" class="language-groovy hljs">test {
    systemProperty "quarkus.test.profile", "foo" <i class="conum" data-value="1"></i><b>(1)</b>
}</code></pre>
</div>
</div>
<div class="paragraph">
<p>or, if you use the Gradle Kotlin DSL:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="kotlin" class="language-kotlin hljs">tasks.test {
    systemProperty("quarkus.test.profile", "foo") <i class="conum" data-value="1"></i><b>(1)</b>
}</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>The <code>foo</code> configuration profile will be used to run the tests.</td>
</tr>
</table>
</div>
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
<div class="paragraph">
<p>It is not possible to use a custom test configuration profile in native mode for now. Native tests are always run using the
<code>prod</code> profile.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="dealing-with-extensions"><a class="anchor" href="#dealing-with-extensions"></a>Dealing with extensions</h2>
<div class="sectionbody">
<div class="paragraph">
<p>From inside a Quarkus project, you can obtain a list of the available extensions with:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./gradlew listExtensions</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can enable an extension using:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./gradlew addExtension --extensions="hibernate-validator"</code></pre>
</div>
</div>
<div class="paragraph">
<p>Extensions are passed using a comma-separated list.</p>
</div>
<div class="paragraph">
<p>The extension name is the GAV name of the extension: e.g. <code>io.quarkus:quarkus-agroal</code>.
But you can pass a partial name and Quarkus will do its best to find the right extension.
For example, <code>agroal</code>, <code>Agroal</code> or <code>agro</code>  will expand to <code>io.quarkus:quarkus-agroal</code>.
If no extension is found or if more than one extensions match, you will see a red check mark  ❌ in the command result.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./gradlew addExtension --extensions="jdbc,agroal,non-exist-ent"
[...]
❌ Multiple extensions matching 'jdbc'
     * io.quarkus:quarkus-jdbc-h2
     * io.quarkus:quarkus-jdbc-mariadb
     * io.quarkus:quarkus-jdbc-postgresql
     Be more specific e.g using the exact name or the full gav.
✅ Adding extension io.quarkus:quarkus-agroal
❌ Cannot find a dependency matching 'non-exist-ent', maybe a typo?
[...]</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can install all extensions which match a globbing pattern:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./gradlew addExtension --extensions="hibernate*"</code></pre>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="development-mode"><a class="anchor" href="#development-mode"></a>Development mode</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Quarkus comes with a built-in development mode.
Run your application with:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./gradlew quarkusDev</code></pre>
</div>
</div>
<div class="paragraph">
<p>You can then update the application sources, resources and configurations.
The changes are automatically reflected in your running application.
This is great to do development spanning UI and database as you see changes reflected immediately.</p>
</div>
<div class="paragraph">
<p><code>quarkusDev</code> enables hot deployment with background compilation, which means that when you modify
your Java files or your resource files and refresh your browser these changes will automatically take effect.
This works too for resource files like the configuration property file.
The act of refreshing the browser triggers a scan of the workspace, and if any changes are detected the
Java files are compiled, and the application is redeployed, then your request is serviced by the
redeployed application. If there are any issues with compilation or deployment an error page will let you know.</p>
</div>
<div class="paragraph">
<p>Hit <code>CTRL+C</code> to stop the application.</p>
</div>
<div class="paragraph">
<p>You can change the working directory the development environment runs on:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="groovy" class="language-groovy hljs">quarkusDev {
    workingDir = rootProject.projectDir
}</code></pre>
</div>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>By default, the <code>quarkusDev</code> task uses <code>compileJava</code> compiler options. These can be overridden by setting the <code>compilerArgs</code> property in the task.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="sect2">
<h3 id="remote-development-mode"><a class="anchor" href="#remote-development-mode"></a>Remote Development Mode</h3>
<div class="paragraph">
<p>It is possible to use development mode remotely, so that you can run Quarkus in a container environment (such as OpenShift)
and have changes made to your local files become immediately visible.</p>
</div>
<div class="paragraph">
<p>This allows you to develop in the same environment you will actually run your app in, and with access to the same services.</p>
</div>
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
Do not use this in production. This should only be used in a development environment. You should not run production applications in dev mode.
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>To do this you must have the <code>quarkus-undertow-websockets</code> extension installed:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./gradlew addExtension --extensions="undertow-websockets"</code></pre>
</div>
</div>
<div class="paragraph">
<p>You must also have the following config properties set:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>quarkus.live-reload.password</code></p>
</li>
<li>
<p><code>quarkus.live-reload.url</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>These can be set via <code>application.properties</code>, or any other way (e.g. system properties, environment vars etc). The
password must be set on both the local and remote processes, while the url only needs to be set on the local host.</p>
</div>
<div class="paragraph">
<p>Start Quarkus in dev mode on the remote host. Now you need to connect your local agent to the remote host:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./gradlew quarkusRemoteDev -Dquarkus.live-reload.url=http://my-remote-host:8080</code></pre>
</div>
</div>
<div class="paragraph">
<p>Now every time you refresh the browser you should see any changes you have made locally immediately visible in the remote
app.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="debugging"><a class="anchor" href="#debugging"></a>Debugging</h2>
<div class="sectionbody">
<div class="paragraph">
<p>In development mode, Quarkus starts by default with debug mode enabled, listening to port <code>5005</code> without suspending the JVM.</p>
</div>
<div class="paragraph">
<p>This behavior can be changed by giving the <code>debug</code> system property one of the following values:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>false</code> - the JVM will start with debug mode disabled</p>
</li>
<li>
<p><code>true</code> - The JVM is started in debug mode and will be listening on port <code>5005</code></p>
</li>
<li>
<p><code>client</code> - the JVM will start in client mode and attempt to connect to <code>localhost:5005</code></p>
</li>
<li>
<p><code>{port}</code> - The JVM is started in debug mode and will be listening on <code>{port}</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>An additional system property <code>suspend</code> can be used to suspend the JVM, when launched in debug mode. <code>suspend</code> supports the following values:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>y</code> or <code>true</code> - The debug mode JVM launch is suspended</p>
</li>
<li>
<p><code>n</code> or <code>false</code> - The debug mode JVM is started without suspending</p>
</li>
</ul>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>You can also run a Quarkus application in debug mode with a suspended JVM using <code>./gradlew quarkusDev -Dsuspend -Ddebug</code> which is a shorthand for <code>./gradlew quarkusDev -Dsuspend=true -Ddebug=true</code>.</p>
</div>
<div class="paragraph">
<p>Then, attach your debugger to <code>localhost:5005</code>.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
<div class="sect1">
<h2 id="import-in-your-ide"><a class="anchor" href="#import-in-your-ide"></a>Import in your IDE</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Once you have a <a href="#project-creation">project generated</a>, you can import it in your favorite IDE.
The only requirement is the ability to import a Gradle project.</p>
</div>
<div class="paragraph">
<p><strong>Eclipse</strong></p>
</div>
<div class="paragraph">
<p>In Eclipse, click on: <code>File &#8594; Import</code>.
In the wizard, select: <code>Gradle &#8594; Existing Gradle Project</code>.
On the next screen, select the root location of the project.
The next screen list the found modules; select the generated project and click on <code>Finish</code>. Done!</p>
</div>
<div class="paragraph">
<p>In a separated terminal, run <code>./gradlew quarkusDev</code>, and enjoy a highly productive environment.</p>
</div>
<div class="paragraph">
<p><strong>IntelliJ</strong></p>
</div>
<div class="paragraph">
<p>In IntelliJ:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>From inside IntelliJ select <code>File &#8594; New &#8594; Project From Existing Sources&#8230;&#8203;</code> or, if you are on the welcome dialog, select <code>Import project</code>.</p>
</li>
<li>
<p>Select the project root</p>
</li>
<li>
<p>Select <code>Import project from external model</code> and <code>Gradle</code></p>
</li>
<li>
<p>Next a few times (review the different options if needed)</p>
</li>
<li>
<p>On the last screen click on Finish</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>In a separated terminal or in the embedded terminal, run <code>./gradlew quarkusDev</code>. Enjoy!</p>
</div>
<div class="paragraph">
<p><strong>Apache NetBeans</strong></p>
</div>
<div class="paragraph">
<p>In NetBeans:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Select <code>File &#8594; Open Project</code></p>
</li>
<li>
<p>Select the project root</p>
</li>
<li>
<p>Click on <code>Open Project</code></p>
</li>
</ol>
</div>
<div class="paragraph">
<p>In a separated terminal or the embedded terminal, go to the project root and run <code>./gradlew quarkusDev</code>. Enjoy!</p>
</div>
<div class="paragraph">
<p><strong>Visual Studio Code</strong></p>
</div>
<div class="paragraph">
<p>Open the project directory in VS Code. If you have installed the Java Extension Pack (grouping a set of Java extensions), the project is loaded as a Gradle project.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="building-a-native-executable"><a class="anchor" href="#building-a-native-executable"></a>Building a native executable</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Native executables make Quarkus applications ideal for containers and serverless workloads.</p>
</div>
<div class="paragraph">
<p>Make sure to have <code>GRAALVM_HOME</code> configured and pointing to GraalVM version 20.1.0.</p>
</div>
<div class="paragraph">
<p>Create a native executable using: <code>./gradlew build -Dquarkus.package.type=native</code>.
A native executable will be present in <code>build/</code>.</p>
</div>
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The <code>buildNative</code> task has been deprecated in favor of
<code>build -Dquarkus.package.type=native</code>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Native related properties can either be added in <code>application.properties</code> file, as command line arguments or in the <code>quarkusBuild</code> task.
Configuring the <code>quarkusBuild</code> task can be done as following:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="groovy" class="language-groovy hljs">quarkusBuild {
    nativeArgs {
        containerBuild = true <i class="conum" data-value="1"></i><b>(1)</b>
        buildImage = "quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java11" <i class="conum" data-value="2"></i><b>(2)</b>
    }
}</code></pre>
</div>
</div>
<div class="colist arabic">
<table>
<tr>
<td><i class="conum" data-value="1"></i><b>1</b></td>
<td>Set <code>quarkus.native.containerBuild</code> property to <code>true</code></td>
</tr>
<tr>
<td><i class="conum" data-value="2"></i><b>2</b></td>
<td>Set <code>quarkus.native.buildImage</code> property to <code>quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java11</code></td>
</tr>
</table>
</div>
<div class="sect2">
<h3 id="build-a-container-friendly-executable"><a class="anchor" href="#build-a-container-friendly-executable"></a>Build a container friendly executable</h3>
<div class="paragraph">
<p>The native executable will be specific to your operating system.
To create an executable that will run in a container, use the following:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true</code></pre>
</div>
</div>
<div class="paragraph">
<p>The produced executable will be a 64 bit Linux executable, so depending on your operating system it may no longer be runnable.
However, it&#8217;s not an issue as we are going to copy it to a Docker container.
Note that in this case the build itself runs in a Docker container too, so you don&#8217;t need to have GraalVM installed locally.</p>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>By default, the native executable will be generated using the <code>quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java11</code> Docker image.</p>
</div>
<div class="paragraph">
<p>If you want to build a native executable with a different Docker image (for instance to use a different GraalVM version),
use the <code>-Dquarkus.native.builder-image=&lt;image name&gt;</code> build argument.</p>
</div>
<div class="paragraph">
<p>The list of the available Docker images can be found on <a href="https://quay.io/repository/quarkus/ubi-quarkus-native-image?tab=tags">quay.io</a>.
Be aware that a given Quarkus version might not be compatible with all the images available.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="running-native-tests"><a class="anchor" href="#running-native-tests"></a>Running native tests</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Run the native tests using:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./gradlew testNative</code></pre>
</div>
</div>
<div class="paragraph">
<p>This task depends on <code>quarkusBuild</code>, so it will generate the native image before running the tests.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="building-uber-jars"><a class="anchor" href="#building-uber-jars"></a>Building Uber-Jars</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Quarkus Gradle plugin supports the generation of Uber-Jars by specifying an <code>--uber-jar</code> argument as follows:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./gradlew quarkusBuild --uber-jar</code></pre>
</div>
</div>
<div class="paragraph">
<p>When building an Uber-Jar you can specify entries that you want to exclude from the generated jar by using the <code>--ignored-entry</code> argument:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="highlightjs highlight"><code data-lang="shell" class="language-shell hljs">./gradlew quarkusBuild --uber-jar --ignored-entry=META-INF/file1.txt</code></pre>
</div>
</div>
<div class="paragraph">
<p>The entries are relative to the root of the generated Uber-Jar. You can specify multiple entries by adding extra <code>--ignored-entry</code> arguments.</p>
</div>
<div class="sect2">
<h3 id="multi-module-gradle"><a class="anchor" href="#multi-module-gradle"></a>Working with multi-module projects</h3>
<div class="paragraph">
<p>By default, Quarkus will not discover CDI beans inside another module.</p>
</div>
<div class="paragraph">
<p>The best way to enable CDI bean discovery for a module in a multi-module project would be to include a <code>META-INF/beans.xml</code> file,
unless it is the main application module already configured with the quarkus-maven-plugin, in which case it will indexed automatically.</p>
</div>
<div class="paragraph">
<p>Alternatively, there is some unofficial <a href="https://plugins.gradle.org/search?term=jandex">Gradle Jandex plugins</a>) that can be used instead of the <code>META-INF/beans.xml</code> file.</p>
</div>
<div class="paragraph">
<p>More information on this topic can be found on the <a href="cdi-reference#bean_discovery">Bean Discovery</a> section of the CDI guide.</p>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="building-with-gradlew-build"><a class="anchor" href="#building-with-gradlew-build"></a>Building with <code>./gradlew build</code></h2>
<div class="sectionbody">
<div class="paragraph">
<p>Starting from 1.1.0.Final, <code>./gradlew build</code> will no longer build the native image. Add <code>-Dquarkus.package.type=native</code> build argument explicitly as explained above if needed.</p>
</div>
</div>
</div>
    </div>
  </div>
</div>

  </div>

  <div class="content project-footer">
  <div class="footer-section">
    <div class="logo-wrapper">
      <a href="/"><img src="/assets/images/quarkus_logo_horizontal_rgb_reverse.svg" class="project-logo" title="Quarkus"></a>
    </div>
  </div>
  <div class="grid-wrapper">
    <p class="grid__item width-3-12">Quarkus is open. All dependencies of this project are available under the <a href='https://www.apache.org/licenses/LICENSE-2.0' target='_blank'>Apache Software License 2.0</a> or compatible license.<br /><br />This website was built with <a href='https://jekyllrb.com/' target='_blank'>Jekyll</a>, is hosted on <a href='https://pages.github.com/' target='_blank'>Github Pages</a> and is completely open source. If you want to make it better, <a href='https://github.com/quarkusio/quarkusio.github.io' target='_blank'>fork the website</a> and show us what you’ve got.</p>

    
      <div class="width-1-12 project-links">
        <span>Navigation</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="/">Home</a></li>
          
            <li><a href="/guides">Guides</a></li>
          
            <li><a href="/community/#contributing">Contribute</a></li>
          
            <li><a href="/faq">FAQ</a></li>
          
            <li><a href="/get-started">Get Started</a></li>
          
        </ul>
      </div>
    
      <div class="width-1-12 project-links">
        <span>Contribute</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="https://twitter.com/quarkusio">Follow us</a></li>
          
            <li><a href="https://github.com/quarkusio">GitHub</a></li>
          
            <li><a href="/security">Security&nbsp;policy</a></li>
          
        </ul>
      </div>
    
      <div class="width-1-12 project-links">
        <span>Get Help</span>
        <ul class="footer-links width-1-12">
          
            <li><a href="https://groups.google.com/forum/#!forum/quarkus-dev">Forums</a></li>
          
            <li><a href="https://quarkusio.zulipchat.com">Chatroom</a></li>
          
        </ul>
      </div>
    

    
      <div class="width-3-12 more-links">
        <span>Quarkus is made of community projects</span>
        <ul class="footer-links">
          
            <li><a href="https://vertx.io/" target="_blank">Eclipse Vert.x</a></li>
          
            <li><a href="https://microprofile.io" target="_blank">Eclipse MicroProfile</a></li>
          
            <li><a href="https://hibernate.org" target="_blank">Hibernate</a></li>
          
            <li><a href="https://netty.io" target="_blank">Netty</a></li>
          
            <li><a href="https://resteasy.github.io" target="_blank">RESTEasy</a></li>
          
            <li><a href="https://camel.apache.org" target="_blank">Apache Camel</a></li>
          
            <li><a href="https://code.quarkus.io/" target="_blank">And many more...</a></li>
          
        </ul>
      </div>
    
  </div>
</div>
  <div class="content redhat-footer">
  <div class="grid-wrapper">
    <span class="licence">
      <i class="fab fa-creative-commons"></i><i class="fab fa-creative-commons-by"></i> <a href="https://creativecommons.org/licenses/by/3.0/" target="_blank">CC by 3.0</a> | <a href="https://www.redhat.com/en/about/privacy-policy">Privacy Policy</a>
    </span>
    <span class="redhat">
      Sponsored by
    </span>
    <span class="redhat-logo">
      <a href="https://www.redhat.com/" target="_blank"><img src="/assets/images/redhat_reversed.svg"></a>
    </span>
  </div>
</div>


  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" integrity="sha384-8gBf6Y4YYq7Jx97PIqmTwLPin4hxIzQw5aDmUg/DDhul9fFpbbLcLh3nTIIDJKhx" crossorigin="anonymous"></script>
  <script type="text/javascript" src="/assets/javascript/mobile-nav.js"></script>
  <script type="text/javascript" src="/assets/javascript/scroll-down.js"></script>
  <script src="/assets/javascript/satellite.js" type="text/javascript"></script>
  <script src="https://quarkus.io/guides/javascript/config.js" type="text/javascript"></script>
  <script src="/assets/javascript/search-filter.js" type="text/javascript"></script>
  <script src="/assets/javascript/back-to-top.js" type="text/javascript"></script>
</body>

</html>
